﻿using Battle.Net;
using Battle.Net.Managers;
using Battle.Net.Model;
using NUnit.Framework;

namespace Aesha.wow.Api.Tests
{

    [TestFixture]
    public class AuthenticationTests
    {
        [Test]
        public void InvalidApplicationTest()
        {
            try
            {
                var conn = new BattleNetConnection(Host.Europe, Locale.en_GB);
                conn.AuthenticationKeys = new AuthenticationKeys("xx", "xx");
                conn.UseCache = false;
                conn.SSL = true;

                var items = new ItemManager();
                items.Connection = conn;
                var item = items.GetItem(19019);
            }
            catch (BattleNetException be)
            {
                Assert.IsTrue(be.ErrorType == ErrorReasons.InvalidApplication);
            }
        }

        [Test]
        public void ValidApplicationTest()
        {
 
            var conn = new BattleNetConnection(Host.Europe, Locale.en_GB);
            conn.AuthenticationKeys = new AuthenticationKeys("4ctgCKp5680yi2Pi", "JOBk0OvcpfgHgHF7");
            conn.UseCache = false;
            conn.SSL = true;

            var items = new ItemManager();
            items.Connection = conn;
            var item = items.GetItem(19019);

            Assert.AreEqual(19019, item.Id);
        }


        [Test]
        public void InvalidApplicationSignatureTest()
        {

            try
            {
                var conn = new BattleNetConnection(Host.Europe, Locale.en_GB);
                conn.AuthenticationKeys = new AuthenticationKeys("4ctgCKp5680yi2Pi", "xx");
                conn.UseCache = false;
                conn.SSL = true;

                var item = conn.Items.GetItem(19019);
            }
            catch (BattleNetException be)
            {
                Assert.IsTrue(be.ErrorType == ErrorReasons.InvalidApplicationSignature);
            }
        }

    }
}
